package com.white.commonlib.adapter.recycle;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;


import com.white.commonlib.engine.img.DefaultImageLoader;

import butterknife.ButterKnife;

/**
 * Created by ytf on 2017/3/31 031.
 * Description:
 */

public abstract class BaseViewHolder<T> extends RecyclerView.ViewHolder
{
    View v;
    T data;
    Context mContext;
    protected DefaultImageLoader il;

    public BaseViewHolder(Context context, View v)
    {
        this(v);
        this.mContext = context;
        il = new DefaultImageLoader(mContext);
    }

    private BaseViewHolder(View itemView)
    {
        super(itemView);
        ButterKnife.bind(this, itemView);
        v = itemView;
    }

    public void setData(T data, int position)
    {
        this.data = data;
        setContent(this.data, position);
    }

    public abstract void setContent(T data, int position);

    public View getItemView()
    {
        return v;
    }

    public void showImg(String url, ImageView iv)
    {
        il.showImg(url, iv);
    }

    public void tx(TextView tv, String str)
    {
        tv.setText(str);
    }
}
